﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UofCASE.AgileProductLinerDSL.Nant.Tasks.Models;
using System.Collections;
using System.IO;
using APLDTests.NantTests.Mocks;

namespace APLDTests.NantTests
{
    [TestClass]
    public class FeatureTest
    {
        Feature f;
        Platform windows, linux, mac;

        [TestInitialize]
        public void setup()
        {
            ITest sharedTest = new DummyTest(true);
            f = new Feature("Feature");
            
            windows = new Platform("Windows");
            f.AddToPlatform(windows, new DummyTest(false));
            f.AddToPlatform(windows, sharedTest);

            linux = new Platform("Linux");
            f.AddToPlatform(linux, new DummyTest(true));
            f.AddToPlatform(linux, sharedTest);
            
            mac = new Platform("Mac OS X");
            f.AddToPlatform(mac, new DummyTest(false));
            f.AddToPlatform(mac, new DummyTest(false));
            f.AddToPlatform(mac, sharedTest);
        }

        [TestMethod]
        public void ReportsFailure()
        {
            Assert.IsTrue(f.Failed(windows));
            Assert.IsFalse(f.Failed(linux));
            Assert.IsTrue(f.Failed(mac));
        }
        
        [TestMethod]
        public void ReportsSuccess()
        {
            Assert.IsFalse(f.Passed(windows));
            Assert.IsTrue(f.Passed(linux));
            Assert.IsFalse(f.Passed(mac));
        }

        [TestMethod]
        public void ProducesSetOfTestKeys()
        {

            IEnumerable<ITestKey> keys = f.TestKeys();
            Assert.AreEqual(5, keys.Count());
        }

        [TestMethod]
        public void AddsTestToSpecificPlatform()
        {
            ITest t = new DummyTest(true);
            f.AddToPlatform(windows, t);
            f.TestsFor(windows).Contains(t);
        }
    }
}
